<?php

class fileCache {
	private $aether;
	private $config;
	private $id;

	function __construct($aether) {
		$this->aether = $aether;
		$this->config = $aether->config;
	}

	public function get($name) {
		$fn = 'app/cache/'.$name;
		if(file_exists($fn)) {
			return file_get_contents($fn);
		} else {
			return false;
		}
	}

	public function isAvailable($name) {
		$fn = 'app/cache/'.$name;
		return file_exists($fn);
	}

	public function set($name, $value) {
		if($aether->getMode()==AETHER_DEVELOPMENT) {
			return false;
		}
		$fn = 'app/cache/'.$name;
		$fh = fopen($fn, 'w');
		fwrite($fh, $value);
		fclose($fh);
	}

	public function getId() {
		if(!$this->id) {
			$this->id = file_get_contents('app/cache/cacheId');
		}
		return $this->id;
	}
}

//EOF
